home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Floppyshop 2
/
Floppyshop - 2.zip
/
Floppyshop - 2.iso
/
art&graf.ix
/
art-0054
/
cv2img09
/
conv2img.txt
< prev
Wrap
Text File
|
1997-04-16
|
9KB
|
204 lines
Convert to .IMG by Craig W. Daymon
======= == ==== == ===== == ======
*** This program is Public Domain ***
Copyright, 1989 - Craig W. Daymon
This is the first release of this program and not all features
are active. There are enough that I thought I would send this one
out to get some response.
**********************************************************************
THIS IS VERSION 0.9 - PLEASE DISTRIBUTE THIS TEXT WITH THE PROGRAM
**********************************************************************
The program will convert the six DEGAS formats, Neochrome, Spectrum
compressed and uncompressed, Mac Paint and Tiny to a monochrome
.IMG format file. These file should be compatible with any programs that
are able to use .IMG files. They have been tested with the .IMG viewer
from Migraph, IMG Quick View, WordUp, PageStream and Easy-Draw as well as
a program I wrote to use the GEM function,v_bit_image(), to print
.IMG files with the help of GDOS. (G+Plus)
PROGRAM OPERATION:
======= =========
The first thing to be displayed is the main selection dialog. From
here you can "click-on" the desired picture format you wish to convert.
You may also exit the program from this dialog.
After selecting a format to convert, the file selector will appear
to allow you to select a file. Selecting 'CANCEL' in the selector will
return you to the dialog. *Make sure to select a file of the same type you
chose from the dialog. (The wildcard in the selector will indicate the
type selected in the dialog.)
When a file has been selected, the dialog will change to indicate that
the conversion has begun and the file will be loaded by the program.
If you are using a monochrome monitor, once the file is loaded the
screen will switch to show the conversion buffer (for color images only)
and you can watch as the image is drawn on the screen. (This worked in
version 0.5. My mono monitor has since died, so let me know if there
are any problems with this feature.)
If you are using a color monitor, the dialog will remain displayed.
When the conversion is finished, the file selector will again appear
and you can choose a name and directory for the converted image. If you
decide not to save the image, you can safely CANCEL and the image will
not be saved.
After saving the image, the main dialog is again displayed to allow
the conversion of another file.
PLEASE SEND COMMENTS:
====== ==== ========
If there is something you would like to see added tothis program,
send me a message through GEnie. My address on GEnie is: C.DAYMON.
If you have any information on any paint formats you would like to see
added or detailed information on formats already supported, please get
in touch with me. (Not all the information I have is accurate and I have
had to make an educated guess or two.) I am especially looking for
information on IFF, Mac (all formats including those for the Mac II) and
Art Director.
The IMG file format (a brief description)
=== === ==== ====== =====================
The first part of any .IMG file is the header. (Sounds reasonable.)
Each item in the header is a 16-bit word.
The format is:
Word | Contents
=============================================================================
0 | IMG version number. ( 0x0001 works best, believe me. )
1 | Header length in words. ( IMPORTANT to check when reading. )
2 | Number of bit planes. ( Also IMPORTANT. 1 = Monochrome. )
3 | Pattern length. ( Part of data compression, usually 2. )
4 | Source device pixel width in microns. (25,400 microns/inch)
5 | Source device pixel height in microns.
6 | Number of pixels per scan line.
7 | Number of scan lines.
Notes:
=====
1) I use a value of 8 for the header length as do most of the
monochrome images available. (No extra information.)
2) The number of bit planes designates the number of colors available.
1 = Monochrome (1 bit, 2 colors), 2 = Medium Res. (2 bits, 4 colors),
4 = Low Res. (4 bits, 16 colors)
3) The number of bit planes is also important in that an IMG file
saves ALL the information for the first bit plane before saving the
information for the second and so on...
4) The source pixel width and height are primarily of use for
determining the aspect ratio of an image. (Personal opinion.)
The 'work_out[]' array used by GEM returns the pixel width and
height for a specified device from the function, v_opnwk() in
words 3 and 4. In the case of the screen, I don't believe these
values are accurate for size, but they do properly indicate the
proper aspect ratio. The ST monochrome screen "device" will return
the value 372 in both word 3 and 4, indicating a 1:1 aspect ratio.
5) Atari markets a product in europe called, HyperPaint, that can
edit and save IMG images. It extends the header by 17 words to
hold the current palette. (Or so I'm told.) Unfortunately,
there is no predefined way to tell WHAT extra information may be
stored in an IMG file. It is up to the program that created the
file and therefore, extra information is often of little use.
Other programs using the IMG format store the palette in separate
files.
The Bit-Map
=== === ===
IMG files are saved a scan-line at a time using one of three methods.
(REMEMBER: All the scan lines for bit plane 0 are stored, followed by
bit plane 1 and so on.) The 3 methods are BIT STRING, PATTERN RUN and
SOLID RUN.
BIT STRING:
=== ======
This is the one I use, it's the easiest. (It's also the least
efficient since it incorporates NO compression.)
Byte 0 : 0x80 - Specifies that the scan-line will be
saved as a bit string.
Byte 1 : 0-255 - Byte count, n. (Number of bytes per
scan-line.)
Byte 2 - n: - A scan-line's worth of raw data for the
bit plane being saved.
SOLID RUN:
===== ===
A solid run means that ALL the bits in the scan-line are either
on or off. It is specified by a single byte whose high-order bit is
set to indicate ON or OFF. The lower seven bits specify the number of
bytes making up the scan-line with all their bits set or cleared.
Thus, up to 127 bytes can make up a scan-line using this method.
Byte = 0x03 = 00000011
Results in a scan-line of 3 bytes with NO bits set.
00000000 00000000 00000000
PATTERN RUN:
======= ===
A pattern run is a number of 'pattern bytes' repeated a specified
number of times. The number of bytes making up a pattern is specified
in word 3 of the header. (Usually 2.)
There are 2 bytes + the pattern bytes in a pattern run.
Byte 0 : 0x00 - Specifies a pattern run. (Mostly)
Byte 1 : 1-255 - Number of bytes in run.
(bytes per scan-line)
Byte 2 - n : - Pattern to be repeated.
*REPLICATION COUNT:
=========== =====
A scan-lines worth of data can be repeated up to 255 times by
preceeding any one of the 3 previous methods with a replication
count. A replication count consists of 4 bytes.
Byte 0 : 0x00 - (A sort-of large pattern run.)
Byte 1 : 0x00 - To avoid confusion with a pattern run.
Byte 2 : 0xFF - ??? (I don't know why.)
Byte 3 : 0-255 - Number of times to repeat scan-line data.
Comments:
========
Other than the REPLICATION COUNT, I don't see why the requirement to
save an entire line using the same method. This information was extracted
from 2 articles appearing in recent british ST magazines.
June 1989 Atari ST User : Page 117
July 1989 ST World (UK) : Page 48
If you are interested in the IMG format, try to get either or both
of these magazines. The first discusses IMG relative to the program
listing in the article, but is still rather complete. The second is
entirely oriented to describing the IMG format.
I guess it wasn't so short after all. Let me know any features you
would like to see added to the program.
-Craig W. Daymon